package com.sfzy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sfzy.entity.Answer;
import com.sfzy.mapper.AnswerMapper;
import com.sfzy.service.AnswerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AnswerServiceImpl implements AnswerService {
    @Autowired
    private AnswerMapper answerMapper;
    @Override
    public int addAnswer(Answer answer) {
        return answerMapper.addAnswer(answer);
    }

    @Override
    public int deleteAnswer(int id) {
        return answerMapper.deleteAnswer(id);
    }

    @Override
    public int updateAnswer(Answer answer) {
        return answerMapper.updateAnswer(answer);
    }

    @Override
    public Answer getAnswerById(int id) {
        return answerMapper.getAnswerById(id);
    }

    @Override
    public PageInfo<Answer> getAnswers(Answer answer, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Answer> answers = answerMapper.getAnswers(answer);
        PageInfo<Answer> pageInfo = new PageInfo<>(answers);
        return pageInfo;
    }
}
